package com.ccrfid.rmc6.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexUtil {
    //包含中文
    public static boolean containChinese(String value) {
        String regex = ".{0,}[\\u4e00-\\u9fa5]{1,}.{0,}";
        Matcher matcher = Pattern.compile(regex).matcher(value);
        if (matcher.matches()) {
            return true;
        } else {
            return false;
        }
    }
    //纯数字
    public static boolean onlyDigital(String value) {
        String regex = "[0-9]{1,}";
        Matcher matcher = Pattern.compile(regex).matcher(value);
        if (matcher.matches()) {
            return true;
        } else {
            return false;
        }
    }
    //标签编号
    public static boolean maybeCardNumber(String value) {
        String regex = "^[1-9]\\d{0,9}";
        Matcher matcher = Pattern.compile(regex).matcher(value);
        if (matcher.matches()) {
            return true;
        } else {
            return false;
        }
    }
    //标签16进制编号
    public static boolean maybeCardHexNumber(String value) {
        if (value != null
                && value.length() == 12
                && value.toUpperCase().startsWith("CC")) {
            return true;
        }
        return false;
    }
    //标签sn
    public static boolean maybeCardSn(String value) {
        if (value != null && value.length() == 32) {
            return true;
        }
        return false;
    }
    //姓名拼音
    public static boolean maybeNameAcronym(String value) {
        String regex = "[a-zA-z~·•. ]{2,10}";
        Matcher matcher = Pattern.compile(regex).matcher(value);
        if (matcher.matches()) {
            return true;
        } else {
            return false;
        }
    }
    //身份证号
    public static boolean isIdNumber(String value) {
        String regex = "(^[1-9]\\d{5}(19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)" +
                "|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{2}$)";
        Matcher matcher = Pattern.compile(regex).matcher(value);
        if (matcher.matches()) {
            return true;
        } else {
            return false;
        }
    }
    //犯罪人员编号
    public static boolean isPersonnelSn(String value) {
        String regex = "^[1-9]\\d{8}(19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{4}";
        Matcher matcher = Pattern.compile(regex).matcher(value);
        if (matcher.matches()) {
            return true;
        } else {
            return false;
        }
    }
    //手机号1xx xxxx xxxx
    public static boolean isPhoneNumber(String value) {
        String regex = "^1[3,4,5,7,8,9][0-9]\\d{8}$";
        Matcher matcher = Pattern.compile(regex).matcher(value);
        if (matcher.matches()) {
            return true;
        } else {
            return false;
        }
    }

    public static void main(String[] args) {
        String cardNumber = "889988059ade";
        System.out.println(maybeCardNumber(cardNumber));
    }
}
